package nl.boektrust.btsoep.shared.model;


public enum URLReferenceType {
	/**
	 * Enum to specify URL types. The  types are used as specified in ONIX 2.1 codelist 73.
	 */
	UNDEFINED,BOOKWEBSITE,PUBLISHER,CONTRIBUTOR_OWN,CONTRIBUTOR_PUBLISHER,AUTHOR_INTERVIEW,AUTHOR_BLOG;
	
	public static String stringValue(URLReferenceType t) {
		String value = new String();
		switch (t) {
		case UNDEFINED: value = "onbekend"; break;
		case BOOKWEBSITE: value = "officiele website boek"; break;
		case PUBLISHER: value = "website uitgever"; break;
		case CONTRIBUTOR_OWN: value = "over en door auteur"; break;
		case CONTRIBUTOR_PUBLISHER: value = "over auteur door uitgever"; break;
		case AUTHOR_INTERVIEW: value = "interview met auteur"; break;
		case AUTHOR_BLOG: value = "auteursblog"; break;
		}
		return value;
		
	}

	public static URLReferenceType parseStringIntoURLReferenceType(String s) {
		for (URLReferenceType t : URLReferenceType.values()) {
			if (URLReferenceType.stringValue(t).equals(s) == true) return t;
		}
		return UNDEFINED;
	}
	
	public static int intValueForOnix(URLReferenceType t) {
		int value = 0;
		if (t == null) {
			System.err.println("URLReferenceType.stringValueForOnix() was called with a null argument");
			return 00;
		}
		switch (t) {
		case UNDEFINED: value = 0; break;
		case BOOKWEBSITE: value = 2; break;
		case PUBLISHER: value = 1; break;
		case CONTRIBUTOR_OWN: value = 6; break;
		case CONTRIBUTOR_PUBLISHER: value = 7; break;
		case AUTHOR_INTERVIEW: value = 25; break;
		case AUTHOR_BLOG: value = 23; break;
		}
		return value;
		
	}
}
